package com.example.hubu20250620.controller;

import com.example.hubu20250620.entity.Movie;
import com.example.hubu20250620.entity.PageData;
import com.example.hubu20250620.service.MovieService;
import com.example.hubu20250620.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.naming.spi.DirStateFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class MovieController {
    @Autowired
    private MovieService movieService;
    @RequestMapping("/getMovie")
    public Result getMovie(){
        List<Movie> movieList8=movieService.getMovieList();
        List<Movie> movieList5=movieService.getMovieListByPlayNumber();
        Map<String,Object> map=new HashMap<>();
        map.put("movieList8",movieList8);
        map.put("movieList5",movieList5);
        return Result.success(map);
    }
    @GetMapping("/getMovieById")
    public Result getMovieId(@RequestParam Integer movieId){
        Movie movie=movieService.getMovieById(movieId);
        return Result.success(movie);
    }
    @GetMapping("getMoviePageList")
    public Result getMoviePageList(PageData pageData,@RequestParam String movieName){
        return Result.success(movieService.getMoviePageList(pageData,movieName));

    }
}
